import type { RuleType, ValidatorRule } from "ant-design-vue/es/form/interface";

/**Key */
export type Key = number | string;
/**YN状态 */
export type BaseStatus = "Y" | "N";
/**任意对象 */
export type AnyObject = Record<string, any>;
/**基础规则 */
export interface BaseRule {
  warningOnly?: boolean;
  /** validate the value from a list of possible values */
  enum?: any[];
  /** validate the exact length of a field */
  len?: number;
  /** validate the max length of a field */
  max?: number;
  /** validation error message */
  message?: string | (() => string);
  /** validate the min length of a field */
  min?: number;
  /** validate from a regular expression */
  pattern?: RegExp;
  /** indicates whether field is required */
  required?: boolean;
  /** transform a value before validation */
  transform?: (value: any) => any;
  /** built-in validation type, available options: https://github.com/yiminghe/async-validator#type */
  type?: RuleType;
  /** treat required fields that only contain whitespace as errors */
  whitespace?: boolean;
  /** Customize rule level `validateTrigger`. Must be subset of Field `validateTrigger` */
  validateTrigger?: string | string[];
  /** Check trigger timing */
  trigger?: "blur" | "change" | Array<"change" | "blur">;
}
/** */
export type AggregationRule = BaseRule &
  Partial<Pick<ValidatorRule, "validator" | "warningOnly">>;
interface ArrayRule extends Omit<AggregationRule, "type"> {
  type: "array";
  defaultField?: RuleObject;
}
export type RuleObject = AggregationRule | ArrayRule;
/**表单校验规则 */
export type FormRule<T = AnyObject> = {
  [key in keyof T]?: RuleObject[];
};

/**控件大小 */
export type SizeType = "middle" | "small" | "large";
